package cn.edu.cdp.dumpling.controller;

import cn.edu.cdp.dumpling.entity.Business;
import cn.edu.cdp.dumpling.service.BusinessService;
import cn.edu.cdp.dumpling.util.R;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.web.bind.annotation.*;

@RestController
//@CrossOrigin
@RequestMapping("/businesses")
public class BusinessController {
    private final BusinessService businessService;

    public BusinessController(BusinessService businessService) {
        this.businessService = businessService;
    }
    @GetMapping("/dumpling")
    public R dumpling() {
        LambdaQueryWrapper<Business> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Business::getName, "随乡饺子馆");
        Business one = businessService.getOne(wrapper);
        if (one != null) {
            return R.success("查询成功", one);
        } else {
            return R.error("查询失败");
        }
    }
}
